home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / test / test_mimetools.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  2KB  |  69 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.4)
  3.  
  4. import unittest
  5. from test import test_support
  6. import string
  7. import StringIO
  8. import mimetools
  9. import sets
  10. msgtext1 = mimetools.Message(StringIO.StringIO('Content-Type: text/plain; charset=iso-8859-1; format=flowed\nContent-Transfer-Encoding: 8bit\n\nFoo!\n'))
  11.  
  12. class MimeToolsTest(unittest.TestCase):
  13.     
  14.     def test_decodeencode(self):
  15.         start = string.ascii_letters + '=' + string.digits + '\n'
  16.         for enc in [
  17.             '7bit',
  18.             '8bit',
  19.             'base64',
  20.             'quoted-printable',
  21.             'uuencode',
  22.             'x-uuencode',
  23.             'uue',
  24.             'x-uue']:
  25.             i = StringIO.StringIO(start)
  26.             o = StringIO.StringIO()
  27.             mimetools.encode(i, o, enc)
  28.             i = StringIO.StringIO(o.getvalue())
  29.             o = StringIO.StringIO()
  30.             mimetools.decode(i, o, enc)
  31.             self.assertEqual(o.getvalue(), start)
  32.         
  33.  
  34.     
  35.     def test_boundary(self):
  36.         s = sets.Set([
  37.             ''])
  38.         for i in xrange(100):
  39.             nb = mimetools.choose_boundary()
  40.             self.assert_(nb not in s)
  41.             s.add(nb)
  42.         
  43.  
  44.     
  45.     def test_message(self):
  46.         msg = mimetools.Message(StringIO.StringIO(msgtext1))
  47.         self.assertEqual(msg.gettype(), 'text/plain')
  48.         self.assertEqual(msg.getmaintype(), 'text')
  49.         self.assertEqual(msg.getsubtype(), 'plain')
  50.         self.assertEqual(msg.getplist(), [
  51.             'charset=iso-8859-1',
  52.             'format=flowed'])
  53.         self.assertEqual(msg.getparamnames(), [
  54.             'charset',
  55.             'format'])
  56.         self.assertEqual(msg.getparam('charset'), 'iso-8859-1')
  57.         self.assertEqual(msg.getparam('format'), 'flowed')
  58.         self.assertEqual(msg.getparam('spam'), None)
  59.         self.assertEqual(msg.getencoding(), '8bit')
  60.  
  61.  
  62.  
  63. def test_main():
  64.     test_support.run_unittest(MimeToolsTest)
  65.  
  66. if __name__ == '__main__':
  67.     test_main()
  68.  
  69.